package com.jdy.haoduoaiteacher.util;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * The http feedback response.
 * 
 * @author zp @ 2015-5-20 上午9:32:06
 */
public class ResponseResult {
  // public int code;
  public String data;
  public int status;

  public ResponseResult(JSONObject result) {
    // this.code = HttpUtils.getCode(result);
    this.data = HttpUtils.getData(result);
    this.status = HttpUtils.getStatus(result);
  }

  public ResponseResult(String result) throws JSONException {
    this(new JSONObject(result));
  }

  public ResponseResult(int code, String data, int status) {
    // this.code = code;
    this.data = data;
    this.status = status;
  }

  /**
   * Tell if we have successfully received information from the host.
   * 
   * @return
   */
  public boolean isSuccess() {
    return this.status == 1;
  }

  @Override
  public String toString() {
    return " " + data + " " + String.valueOf(status);
  }
}